/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = test_t3.c                                          */
/*  NOTE      =                                                    */
/*  DATE      = 2016/04/05 by jikw                                 */
/*******************************************************************/

#include <stdio.h>
#include <assert.h>
#include <CUnit/Basic.h>
#include <CUnit/CUnit.h>

#include "apmtest_cunit.h"
#include "frcomm.h"
#include "frmem.h"
#include "../../src/module/t3/config.h"
#include "__t3_browsemsg_req/__t3_browsemsg_req.h"
#include "__t3_browsemsg_resp/__t3_browsemsg_resp.h"
#include "__t3_destination_analysis/__t3_destination_analysis.h"
#include "__t3_ejb_bytebuff_copy/__t3_ejb_bytebuff_copy.h"
#include "__t3_ejb_class_analysis/__t3_ejb_class_analysis.h"
#include "__t3_ejb_get_funcvalue/__t3_ejb_get_funcvalue.h"
#include "__t3_ejb_getarg/__t3_ejb_getarg.h"
#include "__t3_ejb_getarray/__t3_ejb_getarray.h"
#include "__t3_ejb_getstring_bysemicolon/__t3_ejb_getstring_bysemicolon.h"
#include "__t3_get_class_count/__t3_get_class_count.h"
#include "__t3_get_methodid/__t3_get_methodid.h"
#include "__t3_get_responseid/__t3_get_responseid.h"
#include "__t3_pushmsg_analysis/__t3_pushmsg_analysis.h"
#include "__t3_sendmsg_analysis/__t3_sendmsg_analysis.h"

#include <frservice_mng.h>

static Frmemstat_mng g_st_memstat_mng={0,FR_MEMSTAT_COUNT_MAX};
static pthread_rwlock_t  g_memstat_rwlock = PTHREAD_RWLOCK_INITIALIZER;
static Frmem_env g_st_mem_env = {&g_st_memstat_mng, &g_memstat_rwlock};

int main(int argc, char **argv)
{
    if (fr_slab_init(&g_st_mem_env, MODULE_NAME) == NULL)
        return FR_FAIL;

    apmtest_cunit_registry();

    FunType fun_suites[1024];
    memset(fun_suites, 0x00, sizeof(fun_suites));
    int i_suites_len = sizeof(fun_suites) / sizeof(FunType);
    int i_loop = 0;

    // 加载各个测试组件
    //__t3_browsemsg_req
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_browsemsg_req);
    //__t3_browsemsg_resp
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_browsemsg_resp);
    //__t3_destination_analysis
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_destination_analysis);
    //__t3_ejb_bytebuff_copy
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_ejb_bytebuff_copy);
    //__t3_ejb_class_analysis
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_ejb_class_analysis);
    //__t3_ejb_get_funcvalue
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_ejb_get_funcvalue);
    //__t3_ejb_getarg
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_ejb_getarg);
    //__t3_ejb_getarray
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_ejb_getarray);
    //__t3_ejb_getstring_bysemicolon
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_ejb_getstring_bysemicolon);
    //__t3_get_class_count
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_get_class_count);
    //__t3_get_methodid
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_get_methodid);
    //__t3_get_responseid
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_get_responseid);
    //__t3_pushmsg_analysis
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_pushmsg_analysis);
    //__t3_sendmsg_analysis
    apmtest_cunit_add_suites(fun_suites, i_suites_len, add_suite__t3_sendmsg_analysis);

    for (;i_loop < i_suites_len; i_loop++)
    {
        if (fun_suites[i_loop] != NULL && fun_suites[i_loop]() != 0)
        {
            CU_cleanup_registry();
            return CU_get_error();
        }
    }

    apmtest_cunit_unregistry();

    fr_slab_destroy();

    return 0;
}
